package org.mybatis.spring.boot.study.dataFlow.start_mapperscaner;

import org.mybatis.spring.annotation.MapperScan;
import org.mybatis.spring.boot.study.StudyConfig;
import org.mybatis.spring.boot.study.entity.TjsUser;
import org.mybatis.spring.boot.study.mapper.TjsUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * 内嵌数据库
 * 适用场景1：单元测试
 * 适用场景2：项目前期开发，多人同时操作远程数据库带来的不便
 * @author nicky
 * @date 2021/9/1 上午11:47
 */
@SpringBootApplication
@MapperScan("org.mybatis.spring.boot.mybatisspringbootstudy.mapper")
public class DoTest implements CommandLineRunner {
    @Autowired
    TjsUserMapper tjsUserMapper;

    public static void main(String[] args) {
        StudyConfig.thisDebugNames = "jsUserMapper";
        SpringApplication.run(DoTest.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        TjsUser tjsUser = tjsUserMapper.findByState("CA");
        System.out.println(tjsUser.toString());
    }
}
